package com.luna.utils;

import java.sql.*;

public class JDBC {
    private static final String URL = "jdbc:mysql://localhost:3306/book-note-sys";
    private static final String USER = "root";
    private static final String PASSWORD = "allLoveLain.2001";

    public static Connection getConnection() throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(URL, USER, PASSWORD);
        return connection;
    }

    public static void close(ResultSet resultSet, Statement statement, Connection connection) throws SQLException {
        if (resultSet != null) resultSet.close();
        if (statement != null) statement.close();
        if (connection != null) connection.close();
    }
}
